package com.freesky.provider.order.controller;

import com.freesky.common.pojo.DataTablesResult;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.utils.reponse.JSONResponseDiretor;
import com.freesky.common.dao.entity.Express;
import com.freesky.provider.order.service.IExpressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Freesky
 */
@RestController
@RequestMapping("/express")
public class ExpressController {

    @Autowired
    private IExpressService expressService;


    @GetMapping(value = "/list")
    public DataTablesResult addressList() {

        DataTablesResult result = new DataTablesResult();
        List<Express> list = expressService.getExpressList();
        result.setData(list);
        result.setSuccess(true);
        return result;
    }

    @PutMapping(value = "/add")
    public JSONResponse addExpress(@RequestBody Express express) {
        return expressService.addExpress(express);
    }

    @PostMapping(value = "/update")
    public JSONResponse updateAddress(@RequestBody Express express) {
        return  expressService.updateExpress(express);
    }

    @DeleteMapping(value = "/del/{ids}")
    public JSONResponse delAddress(@PathVariable(value = "ids") int[] ids) {
        return expressService.delExpress(ids);
    }
}
